<template>
  <transition name="slide">
    <div class="modal" v-show="showModal">
      <div class="mask"></div>
      <div class="modal-dialog" :class="[modalType]">
        <div class="modal-header">
          <span>{{title}}</span>
          <a href="javascript:;" class="icon-close" @click="$emit('cancel')"></a>
        </div>
        <div class="modal-body">
          <slot name="body"></slot>
        </div>
        <div class="modal-footer">
          <!-- 传递提交时间到父组件 -->
          <a href="javascript:;" class="btn" v-if="btnType==1" @click="$emit('submit')">{{sureText}}</a>
          <!-- 传递取消到父组件： -->
          <a href="javascript:;" class="btn" v-if="btnType==2" @click="$emit('cancel')">{{cancelText}}</a>
          <div class="btn-group" v-if="btnType==3">
            <!-- 传递提交时间到父组件 -->
            <a href="javascript:;" class="btn" @click="$emit('submit')">{{sureText}}</a>
            <!-- 传递取消到父组件： -->
            <a href="javascript:;" class="btn btn-default" @click="$emit('cancel')">{{cancelText}}</a>
          </div>
        </div>
      </div>
    </div>
  </transition>
</template>
<script>
export default {
  name: "modal",
  // 需要从外部接收的参数：
  props: {
    // 弹框类型：小->small、中->middle、大->large、表单form
    modalType: {
      type: String,
      default: "form"
    },
    // 弹窗标题
    title: String,
    //弹框的按钮:1:确定按钮 2:取消按钮 3:确定取消都有
    btnType: String,
    sureText: {
      type: String,
      default: "确定"
    },
    cancelText: {
      type: String,
      default: "取消"
    },
    // 控制弹窗显示：
    showModal: Boolean
  }
};
</script>
<style  lang="less">

</style>